package com.wang.store.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect  //当前类设置切面类
@Component  //将当前类的对象插件使用交给Spring管理
public class TimerAspect {

    @Around("execution(* com.wang.store.service.impl.*.*(..))")
    public  Object around(ProceedingJoinPoint pjp) throws Throwable {
        //
        //先记录开始时间
        long start = System.currentTimeMillis();
        //调用目标方法login
        Object result = pjp.proceed();
        //记录结束时间
       long  end=  System.currentTimeMillis();
        System.out.println("耗时"+(end-start));
       return result;

    }
}
